load("@bazel_skylib//rules:expand_template.bzl", "expand_template")
load("@rules_cc//cc:defs.bzl", "cc_library")

cc_library(
    name = "xorgproto",
    hdrs = glob(
        ["include/**/*.h"],
        exclude = [
            "include/GL/glxproto.h",
            "include/GL/glxint.h",
            "include/GL/internal/glcore.h",
            "include/X11/extensions/*proto.h",
            "include/X11/extensions/*str.h",
            "include/X11/extensions/*const.h",
            "include/X11/extensions/fontcache.h",
            "include/X11/extensions/fontcacheP.h",
            "include/X11/extensions/lgewire.h",
            "include/X11/extensions/Print.h",
            "include/X11/extensions/windowswm.h",
            "include/X11/extensions/xf86dga.h",
            "include/X11/extensions/xf86misc.h",
            "include/X11/extensions/xf86rush.h",
            "include/X11/extensions/XKBgeom.h",
            "include/X11/extensions/XKBsrv.h",
            "include/X11/extensions/xtrapddmi.h",
            "include/X11/extensions/xtraplib.h",
            "include/X11/extensions/xtraplibp.h",
            "include/X11/extensions/vldXvMC.h",
            "include/X11/dri/xf86dri.h",
            "include/X11/dri/xf86dristr.h",
            "include/X11/dri/xf86driproto.h",
            "include/X11/fonts/fontproto.h",
            "include/X11/fonts/fontstruct.h",
            "include/X11/PM/PMproto.h",
            "include/X11/Xwindows.h",
            "include/X11/Xwinsock.h",
        ],
    ) + [
        "include/X11/Xpoll.h",
    ],
    features = ["parse_headers"],
    includes = ["include"],
    textual_hdrs = glob([
        "include/GL/glxproto.h",
        "include/GL/glxint.h",
        "include/GL/internal/glcore.h",
        "include/X11/extensions/*proto.h",
        "include/X11/extensions/*str.h",
        "include/X11/extensions/*const.h",
        "include/X11/extensions/fontcache.h",
        "include/X11/extensions/fontcacheP.h",
        "include/X11/extensions/lgewire.h",
        "include/X11/extensions/Print.h",
        "include/X11/extensions/windowswm.h",
        "include/X11/extensions/xf86dga.h",
        "include/X11/extensions/xf86misc.h",
        "include/X11/extensions/xf86rush.h",
        "include/X11/extensions/XKBgeom.h",
        "include/X11/extensions/XKBsrv.h",
        "include/X11/extensions/XKBstr.h",
        "include/X11/extensions/xtrapddmi.h",
        "include/X11/extensions/xtraplib.h",
        "include/X11/extensions/xtraplibp.h",
        "include/X11/extensions/vldXvMC.h",
        "include/X11/dri/xf86dri.h",
        "include/X11/dri/xf86dristr.h",
        "include/X11/dri/xf86driproto.h",
        "include/X11/fonts/fontproto.h",
        "include/X11/fonts/fontstruct.h",
        "include/X11/PM/PMproto.h",
        "include/X11/Xwindows.h",
        "include/X11/Xwinsock.h",
    ]),
    visibility = ["//visibility:public"],
)

expand_template(
    name = "xpoll_h",
    out = "include/X11/Xpoll.h",
    substitutions = {
        "@USE_FDS_BITS@": "__fds_bits",
    },
    template = "include/X11/Xpoll.h.in",
)

exports_files(
    [
        "include/X11/keysymdef.h",
        "include/X11/XF86keysym.h",
        "include/X11/Sunkeysym.h",
        "include/X11/DECkeysym.h",
        "include/X11/HPkeysym.h",
    ],
    visibility = ["//visibility:public"],
)
